package com.camel.record.controller;

import com.camel.record.model.ZsCdrinfo;
import com.camel.record.service.WebServerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/web")
public class WebServerController {

    @Autowired
    private WebServerService webServerService;

    @PostMapping("/cdrinfo")
    public String save(@RequestBody Map<String, ZsCdrinfo[]> params) {
        String result = "success";
        try {
            webServerService.saveCdr(params);
        } catch (RuntimeException e) {
            e.printStackTrace();
            result = "error";
        }
        return result;
    }
}
